﻿using Inovout.Business;
using Inovout.Gui.Wpf.ViewModels;

namespace Inovout.Gui.Wpf
{
    public class ViewModelCommand : BaseCommand
    {
        protected Function function;
        private DomainViewModel modelViewModel;

        protected ViewModelCommand(Function function)
            : this(null, function)
        {
        }
        public ViewModelCommand(DomainViewModel modelViewModel, Function function)
        {
            ArgumentGuard.IsNotNull(function, "function");
            this.function = function;
            this.modelViewModel = modelViewModel;
        }

        public override void Execute(object parameter)
        {
            BaseWorkItem workItem = workItem = ComponentRegistry.Resolve(function.WorkItemType) as BaseWorkItem;
            workItem.Function = function;
            workItem.Execute();
        }

        public override bool CanExecute(object parameter)
        {
            return base.CanExecute(parameter);
        }
    }
}
